package com.kly.enums;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;


/**
 * 支付事件
 * @author linqu
 */
public enum PayLogActionEnum {

    REPAY("1", "REPAY"),
    PAY("2", "PAY"),
    ;


    private String code;
    private String name;

    PayLogActionEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public PayLogActionEnum setCode(String code) {
        this.code = code;
        return this;
    }

    public String getName() {
        return name;
    }

    public PayLogActionEnum setName(String name) {
        this.name = name;
        return this;
    }

    public static PayLogActionEnum getEnumByCode(String code) {

        if (Objects.isNull(code)) {
            return null;
        }

        PayLogActionEnum payTypeEnum = null;

        for (PayLogActionEnum p : PayLogActionEnum.values()) {
            if (p.getCode().equals(code)) {
                payTypeEnum = p;
            }
        }
        return payTypeEnum;
    }


    public static List<PayLogActionEnum> getPaymentChannelEnumList() {
        List<PayLogActionEnum> payGatewayEnumList = new ArrayList<>();

        for (PayLogActionEnum paymentChannelEnum : PayLogActionEnum.values()) {
            payGatewayEnumList.add(paymentChannelEnum);
        }

        return payGatewayEnumList;
    }
}
